﻿@model DTcms.Model.BaseModel
@{
    ViewBag.Title = "站内短信息-" + Model.site.seo_title;
    string action = Model.info["action"].ToString();
}
@section HeaderContent{
    <link href="/template/pc/main/default/skin/dragcode.css" rel="stylesheet" />
}
<!--当前位置-->
<div class="section">
    <div class="location">
        <span>当前位置：</span>
        <a href="@Html.linkurl("index")">首页</a> &gt;
        <a href="@Html.linkurl("usercenter", "index")">会员中心</a> &gt;
        <a href="@Html.linkurl("usermessage", "list")">站内短消息</a>
    </div>
</div>
<!--/当前位置-->

<div class="section clearfix">
    <!--页面左边-->
    @Html.Partial("_ucenter_nav")
    <!--/页面左边-->
    <!--页面左边-->
    <div class="right-auto">
        <div class="bg-wrap" style="min-height:765px;">
            @if (action == "system")
            {
                <!--系统消息-->
                <div class="sub-tit">
                    <a class="add" href="@Html.linkurl("usermessage", "add")"><i class="iconfont icon-plus"></i>写消息</a>
                    <ul>
                        <li class="selected">
                            <a href="@Html.linkurl("usermessage", "system")">系统消息</a>
                        </li>
                        <li>
                            <a href="@Html.linkurl("usermessage", "accept")">收件箱</a>
                        </li>
                        <li>
                            <a href="@Html.linkurl("usermessage", "send")">发件箱</a>
                        </li>
                    </ul>
                </div>

                <div class="table-wrap">
                    <table class="layui-table" lay-data="{page:true, id:'ltable'}" lay-filter="ltable">
                        <thead>
                            <tr>
                                <th lay-data="{checkbox:true}"></th>
                                <th lay-data="{field:'title',templet:'#title'}">标题</th>
                                <th lay-data="{field:'is_read',templet:'#is_read'}">状态</th>
                                <th lay-data="{field:'post_time'}">时间</th>
                                <th lay-data="{templet: '#barDemo'}">操作</th>
                            </tr>
                        </thead>
                    </table>
                </div>
                <input id="turl" type="hidden" value="@Html.linkurl("usermessage", "system")" /><!--存在跳转的URL值-->
                <!--/系统消息-->
            }
            else if (action == "accept")
            {
                <!--收件箱-->
                <div class="sub-tit">
                    <a class="add" href="@Html.linkurl("usermessage", "add")"><i class="iconfont icon-reply"></i>写消息</a>
                    <ul>
                        <li>
                            <a href="@Html.linkurl("usermessage", "system")">系统消息</a>
                        </li>
                        <li class="selected">
                            <a href="@Html.linkurl("usermessage", "accept")">收件箱</a>
                        </li>
                        <li>
                            <a href="@Html.linkurl("usermessage", "send")">发件箱</a>
                        </li>
                    </ul>
                </div>

                <div class="table-wrap">
                    <table class="layui-table" lay-data="{page:true, id:'ltable'}" lay-filter="ltable">
                        <thead>
                            <tr>
                                <th lay-data="{checkbox:true}"></th>
                                <th lay-data="{field:'title',templet:'#titleImg'}">发件人</th>
                                <th lay-data="{field:'is_read',templet:'#is_read'}">状态</th>
                                <th lay-data="{field:'post_time'}">时间</th>
                                <th lay-data="{templet: '#barDemo'}">操作</th>
                            </tr>
                        </thead>
                    </table>
                </div>
                <input id="turl" type="hidden" value="@Html.linkurl("usermessage", "accept")" /><!--存在跳转的URL值-->
                <!--/收件箱-->
            }
            else if (action == "send")
            {
                <!--发件箱-->
                <div class="sub-tit">
                    <a class="add" href="@Html.linkurl("usermessage", "add")"><i class="iconfont icon-reply"></i>写消息</a>
                    <ul>
                        <li>
                            <a href="@Html.linkurl("usermessage", "system")">系统消息</a>
                        </li>
                        <li>
                            <a href="@Html.linkurl("usermessage", "accept")">收件箱</a>
                        </li>
                        <li class="selected">
                            <a href="@Html.linkurl("usermessage", "send")">发件箱</a>
                        </li>
                    </ul>
                </div>

                <div class="table-wrap">
                    <table class="layui-table" lay-data="{page:true, id:'ltable'}" lay-filter="ltable">
                        <thead>
                            <tr>
                                <th lay-data="{checkbox:true}"></th>
                                <th lay-data="{field:'title',templet:'#acceptImg'}">收件人</th>
                                <th lay-data="{field:'post_time'}">时间</th>
                                <th lay-data="{templet: '#barDemo'}">操作</th>
                            </tr>
                        </thead>
                    </table>
                </div>
                <input id="turl" type="hidden" value="@Html.linkurl("usermessage", "send")" /><!--存在跳转的URL值-->
                <!--/发件箱-->
            }
            else if (action == "add")
            {
                <!--发布短信息-->
                <div class="sub-tit">
                    <a class="add" href="javascript:history.go(-1);"><i class="iconfont icon-reply"></i>返回</a>
                    <ul>
                        <li class="selected">
                            <a href="javascript:;">发短消息</a>
                        </li>
                    </ul>
                </div>

                <form id="addForm" name="addForm" url="/api/lisence_ajax/user_message_add" class="layui-form">
                    <div class="form-box">
                        <dl class="form-group">
                            <dt>收件人：</dt>
                            <dd>
                                <input name="txtUserName" id="txtUserName" type="text" class="input" datatype="s1-50" nullmsg="请填写收件人用户名" sucmsg=" " />
                            </dd>
                        </dl>
                        <dl class="form-group">
                            <dt>标 题：</dt>
                            <dd>
                                <input name="txtTitle" id="txtTitle" type="text" class="input" datatype="*1-50" sucmsg=" " />
                            </dd>
                        </dl>
                        <dl class="form-group">
                            <dt>内 容：</dt>
                            <dd>
                                <textarea name="txtContent" class="textarea" datatype="*" sucmsg=" "></textarea>
                            </dd>
                        </dl>
                        <dl class="form-group">
                            <dd>
                                <input name="sendSave" type="checkbox" value="true" title="保存到发件箱" checked lay-filter="chkAgree" lay-skin="primary" />
                            </dd>
                        </dl>
                        <dl class="form-group">
                            <dt>激&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;活：</dt>
                            <dd>
                                <input type="hidden" name="imgcodeid" id="imgcodeid" />
                                <div class="authcode2017 clearfix">
                                    <ul class="authcode_btn" id="authcode_btn">
                                        <li data-val="0">0</li>
                                        <li data-val="1">1</li>
                                        <li data-val="2">2</li>
                                        <li data-val="3">3</li>
                                        <li data-val="4">4</li>
                                        <li data-val="5">5</li>
                                        <li data-val="6">6</li>
                                        <li data-val="7">7</li>
                                        <li data-val="8">8</li>
                                        <li data-val="9">9</li>
                                        <div class="success"><s class="s"></s>激活成功</div>
                                    </ul>
                                    <span class="authcode_txt">请点击图中“<span id="authcode_txt"></span>”以激活</span>
                                    <input name="codeindex" id="codeindex" type="hidden" datatype="code" nullmsg="请点击对应字符激活后提交！" sucmsg=" " />
                                    <span class="Validform_checktip"></span>
                                </div>
                            </dd>
                        </dl>
                        <dl class="form-group">
                            <dd>
                                <input id="btnSubmit" name="btnSubmit" type="submit" value="确认发送" class="submit" />
                            </dd>
                        </dl>
                    </div>
                </form>
                <input id="turl" type="hidden" value="@Html.linkurl("usermessage", "add")" /><!--存在跳转的URL值-->
                <!--/发布短信息-->
            }
        </div>
    </div>
    <!--/页面左边-->
</div>
<script type="text/html" id="acceptImg">
    <strong><a href="/user/message/show-{{d.id}}.html">{{d.title}}</a></strong>
    <br />
    收件人：{{d.accept_user_name}}
</script>
<script type="text/html" id="titleImg">
    <strong><a href="/user/message/show-{{d.id}}.html">{{d.title}}</a></strong>
    <br />
    发件人：{{d.post_user_name}}
</script>
<script type="text/html" id="title">
    <a href="/user/message/show-{{d.id}}.html">{{d.title}}</a>
</script>
<script type="text/html" id="is_read">
    {{d.is_read==1?'已读' : '未读'}}
</script>
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
@section Scripts{
    <script type="text/javascript" src="/template/pc/main/default/js/dragcode2.js"></script>
    <script type="text/javascript">
        @{
            if (action == "add")
            {
                <text>
                layui.use(['validform', 'jqueryform'], function () {
                    $('#imgcodeid').iAuthcode();
                    $("#addForm").initValidform('#btnSubmit', 1);
                });
                </text>
            }
            else
            {
                <text>
                layui.use(['table','myaspx'], function () {
                    var table = layui.table, os = layui.myaspx;
                    // 渲染表格
                    os.dataBind('/api/lisence_ajax/get_user_message_list?action=@action');

                    //监听行工具事件
                    table.on('tool(ltable)', function (obj) {
                        var data = obj.data;
                        if (obj.event === 'del') {
                            layer.confirm('确认操作吗？', function (index) {
                                cmswh.request("user_message_delete", "POST", { checkId: data.id });
                                obj.del();
                                layer.close(index);
                            });
                        }
                    });
                });
                </text>
            }
        }
    </script>
}